package com.qh.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * com.qh.dao
 * 26832
 * yjj
 * &#064;description: 数据库接口
 * &#064;author: lxm
 * Jdbc
 * &#064;create: 2024-06-06 20:39
 **/

public class Jdbc {
    private String user="root";
    private String password="root";
    private String url = "jdbc:mysql://localhost:3308/yjj";
    private String driver = "com.mysql.cj.jdbc.Driver";

    public Connection getConnection() throws Exception{
        Connection con  = null;
        Class.forName(driver);
        con = DriverManager.getConnection(url,user,password);
        return con;
    }
    public void close(Connection con, Statement smt, ResultSet rs) throws  Exception{
        if (con!=null){
            con.close();
        }
        if (smt!=null){
            smt.close();
        }
        if (rs!=null){
            rs.close();
        }
    }


}
